<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="com.hnas.core.util.PropertyUtil "%>
<%@page import="com.hnas.core.dto.DataBean"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${pageTitle}</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath }/static/common/multiple/easyui.css"/>
<script type="text/javascript">
(function($){ 

    $.fn.UIdialog = $.fn.dialog; /* 把jquery-ui的dialog另存为UIdialog */ 

})(jQuery)
</script>
<style>
.h_top{display:block; border: 1px solid #dddddd;
       background: #fff;padding:20px 20px;}
.h_top_i{display:inline-block;margin:5px 20px;}
.h_btn{border: 1px solid #cfa972;background: #cfa972;color: #fff;height:33px;
       line-height:34px;padding:0 20px;cursor:pointer}
.m_tab td,.m_tab th{word-wrap:break-word;text-align:center;vertical-align:middle;}
</style>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/common/multiple/jquery.easyui.min.js"></script>
<script type="text/javascript">
	var myEditUrl   = '${pageContext.request.contextPath}/backend/mrch/show/';
	var myAddUrl	= '${pageContext.request.contextPath}/backend/mrch/add';
	var mySaveUrl	= '${pageContext.request.contextPath}/backend/mrch/save';
	var mydeleteUrl	= '${pageContext.request.contextPath}/backend/generateMrchTwoCode/disable/';
	
</script>
</head>
<body>
  <!-- 标题 -->
	<div class="titleBar m_b_20">
		<div class="tit fl b_l_e74a5f">
			<h3 class="cn">商户信息</h3>
			<span class="en">mrch information</span>
		</div>
		<div class="fr"></div>
	</div>
  <!-- end 标题 -->
  <form method="post" action="${pageContext.request.contextPath }/backend/mrch/search" name="searchForm"  id="myForm">
  <input type="hidden" name="pageNo" value="${dto.pageNo}">
  <input type="hidden" name="totalCount" value="${dto.totalCount}">
  <input type="hidden" name="mrchName" value="">
  <input type="hidden" name="mrchId" value="" id="seaMrchId">
  <input type="hidden" name="termNo" value="">
  <!-- 查询 -->
		<div class="h_top m_b_20" >				
		
                   <%--  <div class="h_top_i">
	                	<span>商户编号</span>
	                	<input name="mrchId" value="${dto.mrchId}" style="width:100px;" class="input_style2" type="text" placeholder="">
	               </div> --%>
	               
	                <div class="h_top_i">
	                	<span>商户名称</span>
	                	<input class="easyui-combobox input_style2" width="198px;"  id="seaMrchName">
	               </div>
	               
	                <div class="h_top_i">
	                	<span>终端编号</span>
	                	<input class="easyui-combobox input_style2 " width="198px;"  id="seaTerminalNo">
	               </div>

                    <div class="h_top_i">
                		   <span>每页显示</span>
                			<input style="width:50px;" class="input_style2" type="text" placeholder="" id="pageSize" name="pageSize" value="${dto.pageSize}"> 条
                        </div>
                		 <div class="h_top_i h_btn" id="searchData">
               					<span >查  询</span>             				
               				</div>
 
                		 <div class="h_top_i h_btn" id="addData">
               					<span >添  加</span>             				
               			</div>
		       </div>
	<!-- end 查询 -->
</form>

<%
boolean incDisplayTable = true;
boolean incEditTable = true;
boolean incUploadDiv = false;
boolean incBatchDelete = false;
boolean incDisplayStatus = false;
String uploadTmp="merchantDevice.xls";
%>
<div class="m_b_20">
	<table class="tb_style05 m_tab" width="100%" style="table-layout:fixed;">
		<thead>
			<tr>
				<c:forEach items="${beans}" var="o">
				 <c:if test="${o.display && !o.hidden}"><th>${o.title}</th></c:if>
				</c:forEach>
				<th >操作</th>
			</tr>
		</thead>
		<tbody class="allData">
			<c:forEach items="${pg.list}" var="o">
				<tr>
					<c:forEach items="${beans}" var="o1">
						<c:if test="${o1.display && !o1.hidden}">
							<td style="word-wrap:break-word;">
								<%=String.valueOf(PropertyUtil.getValue(pageContext.getAttribute("o"),((DataBean)pageContext.getAttribute("o1")).getField())).replace("false","否").replace("true","是")%>
							</td>
						</c:if>
					</c:forEach>
					<td >
					    <a href="#" class="c_3366cc btn editData" id="${o.id }">编辑</a>&nbsp;
					    <a href="#" class="c_3366cc btn delData" id="${o.id }">删除</a>						
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<div class="searpage" align="right">
	<div>
		${pg.pageStr}
	</div>
</div>

<!-- 添加start -->
<div class="addDataDiv" id="addDIV" title="添加商户信息">
	<form action="#" id="addFm" method="post" name="addFm" class="addFm" autocomplete="off">
		<input type="hidden" name="id"  value="0">
		<table >
			<tr>
				<td>
					<label>商户名称：</label>
				</td>
				<td>
					<input class="easyui-combobox input_style2" width="198px;" name="mrchName" id="addMrchName">
				    <font color="red">*</font>
				</td>
			</tr>
			<tr>
				<td>
					<label>商户编号：</label>
				</td>
				<td>
					<input id="addMrchId" name="mrchId" value="" style="width:178px;" class="input_style2" readonly="true" >
				    <font color="red">*</font>
				</td>
			</tr>
			<tr>
				<td>
					<label>终端编号：</label>
				</td>
				<td>
					<input class="easyui-combobox input_style2" width="198px;" name="termNo" id="addTerminalNo">
					<font color="red">*</font>
				</td>
			</tr>
			<tr>
				<td>
					<label>终端名称：</label>
				</td>
				<td>
					<input  style="width:178px;" class="input_style2" name="termName" id="addTermName">
				</td>
			</tr>
			<tr>
				<td>
					<label>业务类型：</label>
				</td>
				<td>
					<select id="addBizTypeSelect" name="businessType" style="width: 100px;" class="select ui-widget-content ui-corner-all input_style2">
	 					<c:forEach items="${businessTypeMap }" var="o">
	 						<option value="${o.key }" >${o.value }</option>
	 					</c:forEach>
	 				</select>
				</td>
			</tr>
			<tr>
				<td>
					<label>备注：</label>
				</td>
				<td>
					<textarea id="addRemark" name="remark" value="" style="width:178px;" class="input_style2" type="text" placeholder="">
					</textarea>
				</td>
			</tr>
			<tr>
      			<td colspan="2">
          			<p class="validateTips_deal" align="center"></p>
      			</td>
    		</tr>
		</table>
	</form>
</div>
<!-- 添加end -->

<!-- 编辑start -->
<div class="edtDataDiv" id="edtDIV" title="编辑商户信息">
	<form action="#" id="edtFm" method="post" name="edtFm" class="addFm" autocomplete="off">
		<input type="hidden" name="id" id="primaryId" value="0">
		<table >
			<tr>
				<td>
					<label>商户名称：</label>
				</td>
				<td>
					<input class="easyui-combobox input_style2" width="198px;" name="mrchName" id="edtMrchName">
					<font color="red">*</font>
				</td>
			</tr>
			<tr>
				<td>
					<label>商户编号：</label>
				</td>
				<td>
					<input id="edtMrchId" name="mrchId" value="" style="width:178px;" class="input_style2" readonly="true" >
					<font color="red">*</font>
				</td>
			</tr>
			<tr>
				<td>
					<label>终端编号：</label>
				</td>
				<td>
					<input class="easyui-combobox input_style2" width="198px;" name="eqpIdStr" id="edtTerminalNo">
					<font color="red">*</font>
				</td>
			</tr>
			<tr>
				<td>
					<label>终端名称：</label>
				</td>
				<td>
					<input style="width:178px;" class="input_style2" name="termName" id="edtTermName">
				</td>
			</tr>
			<tr>
				<td>
					<label>业务类型：</label>
				</td>
				<td>
					<select id="edtBizTypeSelect" name="businessType" style="width: 100px;" class="select ui-widget-content ui-corner-all input_style2">
	 					<c:forEach items="${businessTypeMap }" var="o">
	 						<option value="${o.key }" >${o.value }</option>
	 					</c:forEach>
	 				</select>
				</td>
			</tr>
			<tr>
				<td>
					<label>备注：</label>
				</td>
				<td>
					<textarea id="edtRemark" name="remark" value="" style="width:178px;" class="input_style2" type="text" placeholder="">
					</textarea>
				</td>
			</tr>
			<tr>
      			<td colspan="2">
          			<p class="validateTips_deal" align="center"></p>
      			</td>
    		</tr>
		</table>
	</form>
</div>
<!-- 编辑end -->
 <input type="hidden" id="accountId" value="0" />
<script>

$("#searchData").click(function(){
	showMask3("../../images/loading-line.gif","查询中，请稍候...");
	/** 校验输入页数是否非法  **/
	var pageSize=$("#pageSize").val();
	var reg = new RegExp("^[0-9]*$");
	if($.trim(pageSize)!=""){
		if(!reg.test($.trim(pageSize))){
			hideMask();
			$.dialog.alert({title:"查询",content:"每页显示数请输入非负整数"});
			return false;
		}
	}
	if($.trim(pageSize)==""){
		hideMask();
		$.dialog.alert({title:"查询",content:"每页显示数不应许为空"});
		return false;
	}
	var mrchName = $('#seaMrchName').combobox('getText');
	var termNo = $('#seaTerminalNo').combobox('getText');
	var mrchId = $('#seaMrchName').combobox('getValue');
	$('#myForm').find('input[name="mrchName"]').val(mrchName);
	$('#myForm').find('input[name="termNo"]').val(termNo);
	$('#myForm').find('input[name="mrchId"]').val(mrchId);
	doSubmit();
});

function gotoJumpPage(){
	var jumpNum= $("#jumpNum").val();
	$("#search_page_size").val($("#id_page_size").val());
	gotoPage(jumpNum);
	return false;
}

$(function(){
	var termNo = '${dto.termNo}';
	var mrchName = '${dto.mrchName}';
	var mrchId = '${dto.mrchId}';
	$("#seaMrchName").combobox('setValue',mrchId);			
	$("#seaMrchName").combobox('setText',mrchName);	
  	var urlTerminalNo = '${pageContext.request.contextPath }/backend/mrch/getTerminalNo?mrchId=' + mrchId;
    $('#seaTerminalNo').combobox('reload', urlTerminalNo);
    setTimeout(function(){
    	$("#seaTerminalNo").combobox('setValue',termNo);
    	$("#seaTerminalNo").combobox('setText',termNo);	
    },10);
			
});

function query(){
	showMask3("../../images/loading-line.gif","查询中，请稍候...");
	var f = document.searchForm;
	//f.totalCount.value = -1;
	f.submit();
}
	
$('#addMrchName').combobox({
    url:'${pageContext.request.contextPath}/backend/mrch/getMrchs',
    method:'get',
    valueField:'mrch_ID',
    textField:'mrch_NAME',
    panelHeight:'300',
    multiple : false,
    formatter: function (row) {
        var opts = $(this).combobox('options');
        return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
    },
    onShowPanel: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onLoadSuccess: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onSelect: function (row) {
    	 $('#addMrchId').val("");
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', true);
        var mrchId = row.mrch_ID;
        $('#addMrchId').val(mrchId);
        $('#addTerminalNo').combobox('clear');
        $('#addTerminalNo').combobox('loadData', {});
        var urlTerminalNo = '${pageContext.request.contextPath }/backend/mrch/getTerminalNo?mrchId=' + mrchId;
        $('#addTerminalNo').combobox('reload', urlTerminalNo);
    },
    onUnselect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        $('#addMrchId').val("");
        el.find('input.combobox-checkbox')._propAttr('checked', false);
        $('#addTerminalNo').combobox('clear');
    }
});
$('#addTerminalNo').combobox({
    url:'#',
    method:'get',
    valueField:'eqp_NO',
    textField:'eqp_NO',
    panelHeight:'300',
    multiple : false,
    formatter: function (row) {
        var opts = $(this).combobox('options');
        return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
    },
    onShowPanel: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onLoadSuccess: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onSelect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', true);
    },
    onUnselect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', false);
    }
});

$('#edtMrchName').combobox({
    url:'${pageContext.request.contextPath}/backend/mrch/getMrchs',
    method:'get',
    valueField:'mrch_ID',
    textField:'mrch_NAME',
    panelHeight:'300',
    multiple : false,
    formatter: function (row) {
        var opts = $(this).combobox('options');
        return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
    },
    onShowPanel: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onLoadSuccess: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onSelect: function (row) {
    	 $('#edtMrchId').val("");
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', true);
        var mrchId = row.mrch_ID;
        $('#edtMrchId').val(mrchId);
        //$('#edtTerminalNo').combobox('clear');
        //$('#edtTerminalNo').combobox('loadData', {});
        var urlTerminalNo = '${pageContext.request.contextPath }/backend/mrch/getTerminalNo?mrchId=' + mrchId;
        $('#edtTerminalNo').combobox('reload', urlTerminalNo);
    },
    onUnselect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        $('#edtMrchId').val("");
        el.find('input.combobox-checkbox')._propAttr('checked', false);
        $('#edtTerminalNo').combobox('clear');
    }
});
$('#edtTerminalNo').combobox({
    url:'#',
    method:'get',
    valueField:'eqp_NO',
    textField:'eqp_NO',
    panelHeight:'300',
    multiple : false,
    formatter: function (row) {
        var opts = $(this).combobox('options');
        return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
    },
    onShowPanel: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onLoadSuccess: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onSelect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', true);
    },
    onUnselect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', false);
    }
});

$('#seaMrchName').combobox({
    url:'${pageContext.request.contextPath}/backend/mrch/getMrchs',
    method:'get',
    valueField:'mrch_ID',
    textField:'mrch_NAME',
    panelHeight:'300',
    multiple : false,
    formatter: function (row) {
        var opts = $(this).combobox('options');
        return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
    },
    onShowPanel: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onLoadSuccess: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onSelect: function (row) {
    	 $('#seaMrchId').val("");
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', true);
        var mrchId = row.mrch_ID;
        $('#seaMrchId').val(mrchId);
        $('#seaTerminalNo').combobox('clear');
        $('#seaTerminalNo').combobox('loadData', {});
        var urlTerminalNo = '${pageContext.request.contextPath }/backend/mrch/getTerminalNo?mrchId=' + mrchId;
        $('#seaTerminalNo').combobox('reload', urlTerminalNo);
    },
    onUnselect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        $('#seaMrchId').val("");
        el.find('input.combobox-checkbox')._propAttr('checked', false);
        $('#seaTerminalNo').combobox('clear');
    }
});
$('#seaTerminalNo').combobox({
    url:'#',
    method:'get',
    valueField:'eqp_NO',
    textField:'eqp_NO',
    panelHeight:'300',
    multiple : false,
    formatter: function (row) {
        var opts = $(this).combobox('options');
        return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
    },
    onShowPanel: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onLoadSuccess: function () {
        var opts = $(this).combobox('options');
        var target = this;
        var values = $(target).combobox('getValues');
        $.map(values, function (value) {
            var el = opts.finder.getEl(target, value);
            el.find('input.combobox-checkbox')._propAttr('checked', true);
        })
    },
    onSelect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', true);
    },
    onUnselect: function (row) {
        var opts = $(this).combobox('options');
        var el = opts.finder.getEl(this, row[opts.valueField]);
        el.find('input.combobox-checkbox')._propAttr('checked', false);
    }
});


/** 编辑 **/
$(".editData").click(function(){
	var id = $(this).attr("id");
	var editURL = myEditUrl + id;
	$.ajax({
		url : editURL,
		type: 'POST',
		error: function(XMLHttpRequest, textStatus, errorThrown){
			 $.dialog.alert({title:"保存",content:"加载数据异常。"});
		},
		success: function(data){
			$("#primaryId").val(data.id);
			$("#edtMrchName").combobox('setValue', data.mrchId);
			$("#edtMrchName").combobox('setText', data.mrchName);
			$("#edtMrchId").val(data.mrchId);
			//var urlTerminalNo = '${pageContext.request.contextPath }/backend/generateMrchTwoCode/getTerminalNo?mrchId=' + data.mrchId;
			//$('#edtTerminalNo').combobox('reload', urlTerminalNo);	
	 		var termNo = data.termNo;
			$("#edtTerminalNo").combobox('setValue',termNo);			
			$("#edtTerminalNo").combobox('setText',termNo);
			$("#edtTermName").val(data.termName);
			$("#edtRemark").val(data.remark);
		}
	});
	$("#edtDIV").UIdialog("open");
});

/** 添加 **/	 
$("#addData").click(function(){
	clearAllData();
	$("#addDIV").UIdialog("open");
	$('#accountId').val('0');
});

function clearAllData() {
	$("#primaryId").val("0");
	$('#addMrchName').combobox('clear');
	$('#addTerminalNo').combobox('clear');
	$('#addMrchId').val("");
	$('#addTermName').val("");
	$('#addRemark').val("");
}

$("#addDIV").UIdialog({
	autoOpen : false,
	bgiframe: true, 
	height : 420,
	width : 350,
	modal : true,
	resizable : false,
	hide: '',
	show:'',
	zIndex:1000,
	buttons : {
		"保 存" : function() {
			//判空
			var bValid = getValid(1);
			if(bValid){
				var url = myAddUrl;
				showMask3("../../images/loading-line.gif","加载中，请稍候...");
				$.ajax({
					url : url,
					type : 'POST',
					data : {
						"id" : $("#primaryId").val(), 	
						"termNo" : $("#addTerminalNo").combobox('getText'), 
						"mrchId" : $('#addMrchId').val(),
						"termName" : $('#addTermName').val(),
						"businessType":$("#addBizTypeSelect").val(),
						"mrchName" : $("#addMrchName").combobox('getText'),
						"remark" : $("#addRemark").val()
						},
					error : function(XMLHttpRequest, textStatus, errorThrown){
						hideMask();
						//$.dialog.alert({title:"保存",content:"保存异常",callback:"query();"});
						$.dialog.alert({title:"保存",content:"保存异常"});
					},
					success: function(data){
						hideMask();
						if(data.result==1) {
							$("#addDIV").UIdialog("close");
							$.dialog.alert({title:"保存",content:"添加成功",callback:"query();"});
							clearAllData();
							//setTimeout("query();",1000);
						} else {
							//$.dialog.alert({title:"保存",content: data.errorMessage,callback:"query();"});	
							$.dialog.alert({title:"保存",content: data.errorMessage});	
						}
					}
				});  
			}
		},
		"取 消" : function() {
			$(this).UIdialog("close");	
			clearAllData();
		}
	},
	close : function() {
		clearAllData();
	}
});

$("#edtDIV").UIdialog({
	autoOpen : false,
	bgiframe: true, 
	height : 420,
	width : 350,
	modal : true,
	resizable : false,
	hide: '',
	show:'',
	zIndex:1000,
	buttons : {
		"保 存" : function() {
			//判空
			var bValid = getValid(2);
			if(bValid){
				var url = mySaveUrl;
				showMask3("../../images/loading-line.gif","加载中，请稍候...");
				$.ajax({
					url : url,
					type : 'POST',
					data : {
						"id" : $("#primaryId").val(), 	
						"termNo" : $("#edtTerminalNo").combobox('getText'), 
						"mrchId" : $('#edtMrchId').val(),
						"termName" : $('#edtTermName').val(),	
						"businessType":$("#edtBizTypeSelect").val(),
						"mrchName" : $("#edtMrchName").combobox('getText'),
						"remark" : $("#edtRemark").val()
						},
					error : function(XMLHttpRequest, textStatus, errorThrown){
						hideMask();
						//$.dialog.alert({title:"保存",content:"保存异常",callback:"query();"});
						$.dialog.alert({title:"保存",content:"保存异常"});
					},
					success: function(data){
						hideMask();
						if(data.result==1) {
							$("#edtDIV").UIdialog("close");					
							$.dialog.alert({title:"保存",content:"修改成功",callback:"query();"});
							clearAllData();
							//setTimeout("query();",1000);
						} else {
							//$.dialog.alert({title:"保存",content: data.errorMessage,callback:"query();"});	
							$.dialog.alert({title:"保存",content: data.errorMessage});	
						}
					}
				});  
			}
		},
		"取 消" : function() {
			$(this).UIdialog("close");	
			clearAllData();
		}
	},
	close : function() {
		//allFields.val("").removeClass("ui-state-error");
		clearAllData();
	}
});

/** 删除 **/
$(".delData").click(function(){
	var id = $(this).attr("id");
	 $.dialog.confirm({title:"删除",content:"您确定要删除吗",callback:"deleteData('"+id+"');"});
});

//删除
function deleteData(id){
	 $.ajax({
			url : "${pageContext.request.contextPath }/backend/mrch/disable/"+id,
			type : 'POST',
			error : function(XMLHttpRequest, textStatus, errorThrown){
				$.dialog.alert({title:"删除",content:"加载数据异常"});
			},
			success: function(data){
				if(data.result==1) {
				     $.dialog.alert({title:"删除",content:"删除成功"});
				     //setTimeout("query();",1000);
				     query();
				} else {
					$.dialog.alert({title:"删除",content:"删除失败"});	
				}
			}
		});  
}

function getValid(type){
	var terminalNo = $('#addTerminalNo').combobox('getText');
	var mrchName = $('#addMrchName').combobox('getText');
	var mrchId = $('#addMrchId').val();
	if(type==2){
		terminalNo = $('#edtTerminalNo').combobox('getText');
		mrchName = $('#edtMrchName').combobox('getText');
		mrchId = $('#edtMrchId').val();
	}
	
	if(isNull(mrchName)) {
		$.dialog.alert({title:"保存",content:"商户名称不能为空！"});
		return false;
	}
	if(isNull(mrchId)) {
		$.dialog.alert({title:"保存",content:"商户编号不能为空！"});
		return false;
	}
	if(isNull(terminalNo)) {
		$.dialog.alert({title:"保存",content:"终端编号不能为空！"});
		return false;
	}
	return true;
}

</script>
</body>
</html>